package com.page.demo.service.Impl;

import com.page.demo.dao.CarDao;
import com.page.demo.dao.impl.CarDaoImpl;
import com.page.demo.pojo.Car;
import com.page.demo.pojo.ov.CarAndBrand;
import com.page.demo.service.CarService;
import java.util.List;

public class CarServiceImpl implements CarService {
    private CarDao carDao = new CarDaoImpl();
    @Override
    public List<Car> queryAll() {
        List<Car> carList = carDao.queryAll();
        return carList;
    }

    @Override
    public List<Car> queryByPriceAsc() {
        List<Car> carList = carDao.queryByPriceAsc();
        return carList;
    }

    @Override
    public List<Car> queryByPriceDesc() {
        List<Car> carList = carDao.queryByPriceDesc();
        return carList;
    }

    @Override
    public List<CarAndBrand> searchBrandCar(String brand) {
        if (brand == null || brand.isEmpty()){
            List<CarAndBrand> list = carDao.queryCarAndBrand();
            return list;
        }
        List<CarAndBrand> list = carDao.queryCarAndBrand(brand);
        return list;
    }
}
